package com.qire.manhua.dal.dao;

import com.qire.common.dal.dao.IDao;
import com.qire.manhua.model.po.SearchHistoryRecord;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Query;

@Dao
public interface SearchHistoryDao extends IDao<SearchHistoryRecord> {

    @Query("SELECT * FROM SearchHistoryRecord ORDER BY " +
            "CASE WHEN :isAsc = 1 THEN id END ASC, " +
            "CASE WHEN :isAsc = 0 THEN id END DESC")
    List<SearchHistoryRecord> queryAllByIdSort(boolean isAsc);

    /**
     * 删除所有记录
     */
    @Query("DELETE FROM SearchHistoryRecord")
    void deleteAll();

}
